<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    //reverse()//反转数组
    var arr = [13, 1,24, 51, 3];
    console.log(arr.reverse())

    //sort() //
    const ab = (a,b) => {
     return a - b
    }
    const ba = (a,b) => {
     return b - a
    }
    console.log(arr.sort(ab))
    console.log(arr.sort(ba))

  </script>
  
</body>
</html>